package com.nulldev.util.io.bit.miscellaneous;

import java.lang.reflect.Field;

import com.nulldev.util.io.bit.BitIoConstants;

final class BitIoMiscellaneousConstantsHelper {

    @SuppressWarnings({
            "java:S112", // RuntimeException
            "java:S1874", // isAccessible
            "java:S3011" // setAccessible
    })
    static String getString(final String name) {
        try {
            final Field field = BitIoConstants.class.getDeclaredField(name);
            if (!field.isAccessible()) { // NOSONAR
                field.setAccessible(true); // NOSONAR
            }
            return (String) field.get(null);
        } catch (final ReflectiveOperationException roe) {
            throw new RuntimeException("failed to get string for '" + name + "'", roe); // NOSONAR
        }
    }

    private BitIoMiscellaneousConstantsHelper() {
        throw new AssertionError(BitIoMiscellaneousConstants.MESSAGE_INSTANTIATION_IS_NOT_ALLOWED);
    }
}
